package cn.wenhe9.yygh.user.controller;

import cn.wenhe9.yygh.common.result.ResultResponse;
import cn.wenhe9.yygh.model.vo.user.UserInfoQueryVo;
import cn.wenhe9.yygh.user.service.UserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.xml.transform.Result;

/**
 * @author DuJinliang
 * 2022/4/6
 */
@Api(tags = "用户信息管理接口")
@RestController
@RequestMapping("/admin/user")
public class UserController {
    @Resource
    private UserInfoService userInfoService;

    /**
     * 分页查询用户信息
     * @param page Long
     * @param limit Long
     * @param userInfoQueryVo UserInfoQueryVo
     * @return ResultResponse
     */
    @ApiOperation("分页查询用户信息")
    @GetMapping("/{page}/{limit}")
    public ResultResponse getUserListByPage(
            @PathVariable(name = "page") Long page,
            @PathVariable(name = "limit") Long limit,
            UserInfoQueryVo userInfoQueryVo
    ){
        return userInfoService.findUserInfoByPage(page, limit, userInfoQueryVo);
    }


    /**
     * 用户锁定
     * @param userId Long
     * @param status Integer
     * @return
     */
    @ApiOperation("用户锁定")
    @GetMapping("/lock/{userId}/{status}")
    public ResultResponse lockUser(
        @PathVariable(name = "userId") Long userId,
        @PathVariable(name = "status") Integer status
    ){
        return userInfoService.lockUser(userId, status);
    }

    /**
     * 查询用户详情
     * @param userId Long
     * @return ResultResponse
     */
    @ApiOperation("查询用户详情")
    @GetMapping("/{id}")
    public ResultResponse getUserDetail(@PathVariable(name = "id") Long userId){
        return userInfoService.getUserDetailById(userId);
    }

    /**
     * 认证审批
     * @param userId Long
     * @param authStatus Integer
     * @return ResultResponse
     */
    @GetMapping("/approval/{userId}/{authStatus}")
    public ResultResponse approval(
            @PathVariable(name = "userId") Long userId,
            @PathVariable(name = "authStatus") Integer authStatus
    ){
        return userInfoService.approval(userId, authStatus);
    }
}
